import request from '@/utils/request'

export function listDatasource(query) {
	return request({
		url: '/gen/datasource/page',
		method: 'get',
		params: query
	})
}

export const useDataSourceTestApi = (id) => {
	return request({
		url: '/gen/datasource/test/' + id,
		method: 'get',
	})
}

export const useDataSourceApi = (id) => {
	return request({
		url: '/gen/datasource/' + id,
		method: 'get',
	})
}

export const useDataSourceListApi = () => {
	return request({
		url: '/gen/datasource/list',
		method: 'get',
	})
}

export const useDataSourceSubmitApi = (dataForm) => {
	if (dataForm.id) {
		return request({
			url: '/gen/datasource',
			method: 'put',
			data: dataForm
		})
	} else {
		return request({
			url: '/gen/datasource',
			method: 'post',
			data: dataForm
		})
	}
}

export const useDataSourceTableListApi = (id) => {
	return request({
		url: '/gen/datasource/table/list/' + id,
		method: 'get',
	})
}

export const deleteDataSource = (ids) => {
	return request({url:'/gen/datasource',method:'delete',data:ids})
}

